package com.Cychat.doctor.service.impl;

import com.Cychat.commons.entity.pojo.Doctor;
import com.Cychat.commons.entity.vo.DoctorVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.Cychat.doctor.mapper.DoctorMapper;
import com.Cychat.doctor.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Auther: 谢宝辉  <br/>
 * Date: 2025/11/3:17:17  <br/>
 * Description: 医生Service实现类
 */
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements DoctorService {
    @Autowired
    private DoctorMapper doctorMapper;
    @Override
    public List<DoctorVo> getAllDoctors() {
        return baseMapper.getAllDoctors();
    }

    @Override
    public IPage<DoctorVo> getDoctorVoPage(Page<Doctor> page, Integer hospitalId, Integer departmentId) {
        return baseMapper.selectDoctorVoPage(page, hospitalId, departmentId);
    }

    @Override
    public DoctorVo getDoctorVoByUserInfoId(Integer userinfoId) {
        return baseMapper.selectDoctorVoByUserInfoId(userinfoId);
    }

    @Override
    public DoctorVo getDoctorVoById(Integer doctorId) {
        return baseMapper.selectDoctorVoById(doctorId);
    }

    @Override
    public boolean updateDoctor(Doctor doctor) {
        return updateById(doctor);
    }

    @Override
    public boolean checkUserInfoIdExists(Integer userinfoId) {
        QueryWrapper<Doctor> wrapper = new QueryWrapper<>();
        wrapper.eq("userinfo_id", userinfoId);
        return count(wrapper) > 0;
    }
}
